package com.yangrd.easypress.web;

import com.yangrd.easypress.model.Post;
import com.yangrd.easypress.repositoy.PostRepository;
import lombok.AllArgsConstructor;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.*;

/**
 * @author yangrd
 * @date 2019/4/2
 **/
@AllArgsConstructor

@RestController
@RequestMapping("admin/post")
public class PostController {

    private PostRepository repository;

    @PostMapping
    @ResponseStatus(HttpStatus.CREATED)
    public void save(@RequestBody ReqPost reqPost){
        repository.save(Post.of(reqPost.getTitle(),reqPost.getContent()));
    }

}
